package com.athui.bean.task;

import java.io.Serializable;
import java.time.Duration;
import java.time.LocalDateTime;

/**
 * @description: TODO
 * @autor: zhangzhonghui
 * @create: 2024-08-28 22:21
 * @Version: 1.0
 */
public class SameTask implements Serializable {

    public static final int FILE_TASK_TYPE =1;
    public static final int JDBC_TASK_TYPE =1;
    public static final int QUEUE_TASK_TYPE =1;

    /**
     * @description: TODO 任务类型
     * @author: 阿辉大人
     * @create: 2024/8/28 22:22
     * @version: 1.0
    **/
    private int taskType;

    /**
     * @description: TODO 任务开始时间
     * @author: 阿辉大人
     * @create: 2024/8/28 22:30
     * @version: 1.0
    **/
    private LocalDateTime taskStartTime = LocalDateTime.now();

    /**
     * @description: TODO 记录任务的迭代次数
     * @author: 阿辉大人
     * @create: 2024/8/28 23:01
     * @version: 1.0
    **/
    private Long iterationSize;

    /**
     * @description: TODO 写入到 侧输出流的次数
     * @author: 阿辉大人
     * @create: 2024/8/28 23:05
     * @version: 1.0
    **/
    private Long outPutTagSize = 0L;

    /**
     * @description: TODO 无效列个数
     * @author: 阿辉大人
     * @create: 2024/8/28 23:17
     * @version: 1.0
    **/
    private Long invalidColumnCount = 0L;


    /**
     * @description: TODO 耗时
     * @author: 阿辉大人
     * @create: 2024/8/28 22:32
     * @version: 1.0
    **/
    private String consumingTime;


    public int getTaskType() {
        return taskType;
    }


    public void setTaskType(int taskType) {
        this.taskType = taskType;
    }

    public LocalDateTime getTaskStartTime() {
        return taskStartTime;
    }

    public LocalDateTime getTaskEndTime() {
        return LocalDateTime.now();
    }


    public String getConsumingTime() {
        // 计算两者之间的时间差
        Duration duration = Duration.between(taskStartTime, getTaskEndTime());

        // 获取小时、分钟和秒数
        long hours = duration.toHours();
        long minutes = duration.toMinutes() % 60; // 取模运算得到剩余分钟数
        long seconds = duration.getSeconds() % 60; // 取模运算得到剩余秒数

        // 输出格式化结果
        return String.format("%d时%d分%d秒", hours, minutes, seconds);
    }

    public Long getIterationSize() {
        return iterationSize;
    }

    public void setIterationSize(Long iterationSize) {
        this.iterationSize = iterationSize;
    }

    public Long getOutPutTagSize() {
        return outPutTagSize;
    }

    public void setOutPutTagSize(Long outPutTagSize) {
        this.outPutTagSize = outPutTagSize;
    }

    public Long getInvalidColumnCount() {
        return invalidColumnCount;
    }

    public void setInvalidColumnCount(Long invalidColumnCount) {
        this.invalidColumnCount = invalidColumnCount;
    }

    @Override
    public String toString() {
        return "SameTask{" +
                "taskType=" + taskType +
                ", taskStartTime=" + taskStartTime +
                ", taskEndTime="+ getTaskEndTime()+
                ", iterationSize=" + iterationSize +
                ", outPutTagSize=" + outPutTagSize +
                ", invalidColumnCount=" + invalidColumnCount +
                ", consumingTime='" + getConsumingTime() + '\'' +
                '}';
    }
}
